package main

import (
	"fmt"
	"time"
)

func main() {
	now := time.Now()
	fmt.Printf("now  %T , %v \n", now, now)
	dateJanuary := time.Date(2020, 1, 12, 13, 20, 30, 0, time.Local)
	fmt.Println("dateJanuary  ==  ", dateJanuary)

	parse2020, err := time.Parse("2006-01-02 15:04:05", "2020-12-13 20:20:20")
	fmt.Println("parse2020  ==  ", parse2020, "  err  == ", err)
	format2020 := parse2020.Format("2006-01-02 15:04:05")
	fmt.Println("format2020  ==  ", format2020, "  err  == ", err)

	date2022 := now.AddDate(1, 1, 1)
	date2022Format := date2022.Format("2006-01-02 15:04:05")
	fmt.Println("date2022Format  ==  ", date2022Format)
	hours2022 := date2022.Sub(now).Hours()
	fmt.Println("hours2022  ==  ", hours2022)

	//时间戳
	nano2022 := date2022.UnixNano()
	fmt.Println("nano2022  ==  ", nano2022)
	unix2022 := date2022.Unix()
	fmt.Println("unix2022  ==  ", unix2022)

}
